#include <buola/gui.h>

#include <buola/gui/dnd/cdroptarget.h>
#include <buola/gui/cwindow.h>

namespace buola { namespace gui {

std::vector<CDropTarget*> CDropTarget::mTargets;

CDropTarget::CDropTarget()
{
    mTargets.push_back(this);
}

CDropTarget::~CDropTarget()
{
    mTargets.erase(std::find(mTargets.begin(),mTargets.end(),this));
}

void CDropTarget::AddDropWindow(const PWindow &pWindow)
{
    mDropWindowList.push_back(pWindow);
}

CDropTarget *CDropTarget::GetTarget(const PWindow &pWindow)
{
    for(int i=0;i<mTargets.size();i++)
    {
        for(int j=0;j<mTargets[i]->mDropWindowList.size();j++)
        {
            if(mTargets[i]->mDropWindowList[j]==pWindow) return mTargets[i];
        }
    }

    return nullptr;
}

/*namespace gui*/ } /*namespace buola*/ }
